package manager

import (
	"goapi/entity"
	"goapi/model"
)

func SelectManagerList(manager entity.Manager, page, limit int) ([]entity.Manager, error) {
	var list []entity.Manager
	if err := model.DB.Self.Table(manager.TableName()).Where(manager).Select("*").Offset(page - 1).Limit(limit).Find(&list).Error; err != nil {
		return list, err
	}
	return list, nil
}

func SelectManagerInfoByAccount(account string) (entity.Manager, error) {
	var info entity.Manager
	if err := model.DB.Self.Table(info.TableName()).Select("*").Where("account=?", account).First(&info).Error; err != nil {
		return info, err
	}
	return info, nil
}
